<template>
	<g-page :is-tabbar="true">
		<waterfall-flow :list="list" @click="choose"></waterfall-flow>
	</g-page>
</template>

<script>
	// 瀑布流组件
	import WaterfallFlow from '@/components/nairenk-waterfall-flow/nairenk-waterfall-flow.vue';
	import {
		getDynamicsApi
	} from "@api"
	export default {
		components: {
			WaterfallFlow
		},		
		name: "dynamics",
		data() {
			return {
				data: [],
				page: 0,
				start: 0,
				size: 5,
				list: [], // 列表
			}
		},
		onLoad() {
			this.getList(this.page);
		},
		onReachBottom() {
			this.page++;
			this.getList(this.page);
		},
		methods: {
			// 选中
			choose(item) {
				// item 返回选中 JSON 对象
				console.log(item)
			},
			// 模拟加载数据
			async getList(page) {
				let that = this;
				let data = [];
				uni.showLoading({
					title: '加载中...'
				})
				await getDynamicsApi({page: page, size: that.size}).then(res=>{
					data = res;
					for (let i = 0; i < res.length; i++) {
						data.create_time = this.$u.timeFrom(res.create_time, false);
						data.issue_imags = this.$t.getImageUrl(res.issue_imags);
						data.avatar_name = this.$t.getImageUrl(res.avatar_name);
					}
				})
				console.log("data", data);					
				if (page == 0)
					that.list = data;
				else
					that.list = that.list.concat(data);
				uni.hideLoading();					
			}
		}
	}
</script>

<style>
</style>
